#ifndef CREATEORDERDLG_H
#define CREATEORDERDLG_H

#include <QMutex>
#include <QWidget>
#include <QStringList>
#include "include/TrService.h"
#include "include/TrManager.h"
#include "NoFocusDelegate.h"


namespace Ui {
class CreateOrderDlg;
}

class CreateOrderDlg : public QWidget, public CTrReceiver
{
    Q_OBJECT

public:
    explicit CreateOrderDlg(QWidget *parent = nullptr);
    ~CreateOrderDlg() override;
    virtual void OnReceiveData(Tr_ResponseID rId, void* wParam, void* lParam) override;

    QString         m_curInstr;
    void            Init_CtrlWidget();
    QVector<CThostFtdcOrderField>               m_vOrders;
    void            InsertTable();
    void            coverOrder(CThostFtdcOrderField* order);
    void            rowInsert(CThostFtdcOrderField* order);
    void            rowUpdateState(CThostFtdcOrderField* order, int iRow);
    bool            isTradingOrder(CThostFtdcOrderField *pOrder);
private:
    Ui::CreateOrderDlg *ui;
    QStringList     m_InstrList;
    QMutex          m_Mutex;
    CThostFtdcDepthMarketDataField  tmpData;
public slots:
    void    Slot_InstrumentChange(QString instr);
    void    Slot_BtnCreateBuy();
    void    Slot_BtnCreateSell();
    void    Slot_BtnCloseBuy();
    void    Slot_BtnCloseSell();
    void    Slot_OppStateChange(int state);
    void    Slot_PriceChange(QString price);
    void    Slot_tableRightClick(QPoint point);
    void    Slot_clickRevokeOrder();
signals:
    void    signal_revokeorder(TThostFtdcSequenceNoType BrokerOrderSeq);
};

#endif // CREATEORDERDLG_H
